package com.qf.controller;

import com.qf.pojo.Shop;
import com.qf.service.ShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * 商品的控制器
 */
@Controller
@RequestMapping("/shop")
public class ShopController {
    //注入Service
    @Autowired
    private ShopService shopService;
    /**
     * 查询所有商品
     * @return
     */
    @RequestMapping("/findAll")
    public String findAllShop(Model model){
        List<Shop> list = shopService.getAllShop();

        //将它存储Model中
        model.addAttribute("list",list);
        return "shop_list";
    }
}
